# ~*~ coding: utf-8 ~*~
from apps.blueprints import tasks_blueprint

from .views import CrontabListAPI, CrontabListView, CrontabCreateView, CrontabUpdateView, CrontabDeleteView
from .views import IntervalListAPI, IntervalListView, IntervalCreateView, IntervalUpdateView, IntervalDeleteView
from .views import PeriodicTaskListAPI, PeriodicTaskListView, PeriodicTaskCreateView, PeriodicTaskUpdateView, \
    PeriodicTaskDeleteView, PeriodicTaskExecuteView, PeriodicTaskHistoryListAPI, PeriodicTaskHistoryListView, \
    PeriodicTaskHistoryLogAPI, PeriodicTaskHistoryKillAPI, PeriodicTaskHistoryDeleteView
from .views import ScriptListAPI, ScriptListView, ScriptCreateView, ScriptUpdateView, ScriptDeleteView
from .views import FunctionListAPI, FunctionListView, FunctionCreateView,\
    FunctionUpdateView, FunctionDeleteView, FunctionItemAPI

# ------------------- periodic -------------------

# crontab
tasks_blueprint.add_url_rule('/api/crontab/', view_func=CrontabListAPI.as_view('api-crontab-list'))
tasks_blueprint.add_url_rule('/crontab/', view_func=CrontabListView.as_view('crontab-list'))
tasks_blueprint.add_url_rule('/crontab/create/', view_func=CrontabCreateView.as_view('crontab-create'))
tasks_blueprint.add_url_rule('/crontab/<uuid:pk>/update/', view_func=CrontabUpdateView.as_view('crontab-update'))
tasks_blueprint.add_url_rule('/crontab/<uuid:pk>/delete/', view_func=CrontabDeleteView.as_view('crontab-delete'))

# interval
tasks_blueprint.add_url_rule('/api/interval/', view_func=IntervalListAPI.as_view('api-interval-list'))
tasks_blueprint.add_url_rule('/interval/', view_func=IntervalListView.as_view('interval-list'))
tasks_blueprint.add_url_rule('/interval/create/', view_func=IntervalCreateView.as_view('interval-create'))
tasks_blueprint.add_url_rule('/interval/<uuid:pk>/update/', view_func=IntervalUpdateView.as_view('interval-update'))
tasks_blueprint.add_url_rule('/interval/<uuid:pk>/delete/', view_func=IntervalDeleteView.as_view('interval-delete'))

# task
tasks_blueprint.add_url_rule('/api/task/', view_func=PeriodicTaskListAPI.as_view('api-task-list'))
tasks_blueprint.add_url_rule('/task/', view_func=PeriodicTaskListView.as_view('task-list'))
tasks_blueprint.add_url_rule('/task/create/', view_func=PeriodicTaskCreateView.as_view('task-create'))
tasks_blueprint.add_url_rule('/task/<uuid:pk>/update/', view_func=PeriodicTaskUpdateView.as_view('task-update'))
tasks_blueprint.add_url_rule('/task/<uuid:pk>/delete/', view_func=PeriodicTaskDeleteView.as_view('task-delete'))
tasks_blueprint.add_url_rule('/task/<uuid:pk>/execute/', view_func=PeriodicTaskExecuteView.as_view('task-execute'))

tasks_blueprint.add_url_rule('/api/history/', view_func=PeriodicTaskHistoryListAPI.as_view('api-history-list'))
tasks_blueprint.add_url_rule('/api/history/<path:filename>/',
                             view_func=PeriodicTaskHistoryLogAPI.as_view('api-history-log'))
tasks_blueprint.add_url_rule('/api/history/<uuid:pk>/kill/',
                             view_func=PeriodicTaskHistoryKillAPI.as_view('api-history-kill'))
tasks_blueprint.add_url_rule('/history/', view_func=PeriodicTaskHistoryListView.as_view('history-list'))
tasks_blueprint.add_url_rule('/history/<uuid:pk>/delete/',
                             view_func=PeriodicTaskHistoryDeleteView.as_view('history-delete'))

# script
tasks_blueprint.add_url_rule('/api/script/', view_func=ScriptListAPI.as_view('api-script-list'))
tasks_blueprint.add_url_rule('/script/', view_func=ScriptListView.as_view('script-list'))
tasks_blueprint.add_url_rule('/script/create/', view_func=ScriptCreateView.as_view('script-create'))
tasks_blueprint.add_url_rule('/script/<uuid:pk>/update/', view_func=ScriptUpdateView.as_view('script-update'))
tasks_blueprint.add_url_rule('/script/<uuid:pk>/delete/', view_func=ScriptDeleteView.as_view('script-delete'))

# function
tasks_blueprint.add_url_rule('/api/function/', view_func=FunctionListAPI.as_view('api-function-list'))
tasks_blueprint.add_url_rule('/function/', view_func=FunctionListView.as_view('function-list'))
tasks_blueprint.add_url_rule('/function/create/', view_func=FunctionCreateView.as_view('function-create'))
tasks_blueprint.add_url_rule('/function/<uuid:pk>/update/', view_func=FunctionUpdateView.as_view('function-update'))
tasks_blueprint.add_url_rule('/function/<uuid:pk>/delete/', view_func=FunctionDeleteView.as_view('function-delete'))
tasks_blueprint.add_url_rule('/function/<uuid:pk>/item/', view_func=FunctionItemAPI.as_view('function-item'))

# ------------------- realtime -------------------

from .views import InventoryGroupListAPI, InventoryGroupListView, InventoryGroupUpdateView, \
    InventoryGroupCreateView, InventoryGroupDeleteView
from .views import InventoryHostVariableListAPI, InventoryHostVariableListView, InventoryHostVariableUpdateView, \
    InventoryHostVariableCreateView, InventoryHostVariableDeleteView
from .views import AdHocListAPI, AdHocListView, AdHocUpdateView, AdHocCreateView,\
    AdHocDeleteView, AdHocExecuteView
from .views import PlayBookListAPI, PlayBookListView, PlayBookUpdateView, \
    PlayBookCreateView, PlayBookDeleteView, PlayBookExecuteView
from .views import AdHocExecuteLogAPI, AdHocExecuteLogView, PlayBookExecuteLogAPI, PlayBookExecuteLogView, \
    PlayBookFileView
from .views import RoleListAPI, RoleListView, RoleUpdateView, RoleCreateView, RoleDeleteView, RoleDetailView, \
    RoleExecuteView, RoleNodeTreeAPI, RoleNodeAddChildrenAPI, RoleNodeMoveChildrenAPI, RoleNodeDeleteAPI, \
    RoleNodeRenameAPI, RoleNodeCopyAPI, RoleNodeFileContentAPI, RoleNodeFileUploadAPI, RoleUploadView, \
    RoleExecuteLogAPI, RoleExecuteLogView

# group
tasks_blueprint.add_url_rule('/api/group/', view_func=InventoryGroupListAPI.as_view('api-group-list'))
tasks_blueprint.add_url_rule('/group/', view_func=InventoryGroupListView.as_view('group-list'))
tasks_blueprint.add_url_rule('/group/create/', view_func=InventoryGroupCreateView.as_view('group-create'))
tasks_blueprint.add_url_rule('/group/<uuid:pk>/update/', view_func=InventoryGroupUpdateView.as_view('group-update'))
tasks_blueprint.add_url_rule('/group/<uuid:pk>/delete/', view_func=InventoryGroupDeleteView.as_view('group-delete'))

# host
tasks_blueprint.add_url_rule('/api/host/', view_func=InventoryHostVariableListAPI.as_view('api-host-list'))
tasks_blueprint.add_url_rule('/host/', view_func=InventoryHostVariableListView.as_view('host-list'))
tasks_blueprint.add_url_rule('/host/create/', view_func=InventoryHostVariableCreateView.as_view('host-create'))
tasks_blueprint.add_url_rule('/host/<uuid:pk>/update/', view_func=InventoryHostVariableUpdateView.as_view('host-update'))
tasks_blueprint.add_url_rule('/host/<uuid:pk>/delete/', view_func=InventoryHostVariableDeleteView.as_view('host-delete'))

# adhoc
tasks_blueprint.add_url_rule('/api/adhoc/', view_func=AdHocListAPI.as_view('api-adhoc-list'))
tasks_blueprint.add_url_rule('/adhoc/', view_func=AdHocListView.as_view('adhoc-list'))
tasks_blueprint.add_url_rule('/adhoc/create/', view_func=AdHocCreateView.as_view('adhoc-create'))
tasks_blueprint.add_url_rule('/adhoc/<uuid:pk>/update/', view_func=AdHocUpdateView.as_view('adhoc-update'))
tasks_blueprint.add_url_rule('/adhoc/<uuid:pk>/delete/', view_func=AdHocDeleteView.as_view('adhoc-delete'))
tasks_blueprint.add_url_rule('/adhoc/execute/', view_func=AdHocExecuteView.as_view('adhoc-execute'))

# playbook
tasks_blueprint.add_url_rule('/api/playbook/', view_func=PlayBookListAPI.as_view('api-playbook-list'))
tasks_blueprint.add_url_rule('/playbook/', view_func=PlayBookListView.as_view('playbook-list'))
tasks_blueprint.add_url_rule('/playbook/create/', view_func=PlayBookCreateView.as_view('playbook-create'))
tasks_blueprint.add_url_rule('/playbook/<uuid:pk>/update/', view_func=PlayBookUpdateView.as_view('playbook-update'))
tasks_blueprint.add_url_rule('/playbook/<uuid:pk>/delete/', view_func=PlayBookDeleteView.as_view('playbook-delete'))
tasks_blueprint.add_url_rule('/playbook/execute/', view_func=PlayBookExecuteView.as_view('playbook-execute'))

# role
tasks_blueprint.add_url_rule('/api/role/', view_func=RoleListAPI.as_view('api-role-list'))
tasks_blueprint.add_url_rule('/role/', view_func=RoleListView.as_view('role-list'))
tasks_blueprint.add_url_rule('/role/create/', view_func=RoleCreateView.as_view('role-create'))
tasks_blueprint.add_url_rule('/role/upload/', view_func=RoleUploadView.as_view('role-upload'))
tasks_blueprint.add_url_rule('/role/<uuid:pk>/update/', view_func=RoleUpdateView.as_view('role-update'))
tasks_blueprint.add_url_rule('/role/<uuid:pk>/delete/', view_func=RoleDeleteView.as_view('role-delete'))
tasks_blueprint.add_url_rule('/role/<uuid:pk>/detail/', view_func=RoleDetailView.as_view('role-detail'))
tasks_blueprint.add_url_rule('/role/execute/', view_func=RoleExecuteView.as_view('role-execute'))

# role node
tasks_blueprint.add_url_rule(
    '/api/role/node/tree/',
    view_func=RoleNodeTreeAPI.as_view('api-node-tree')
)
tasks_blueprint.add_url_rule(
    '/api/role/node/<uuid:pk>/add/children/',
    view_func=RoleNodeAddChildrenAPI.as_view('api-node-add-children')
)
tasks_blueprint.add_url_rule(
    '/api/role/node/<uuid:pk>/move/children/',
    view_func=RoleNodeMoveChildrenAPI.as_view('api-node-move-children')
)
tasks_blueprint.add_url_rule(
    '/api/role/node/<uuid:pk>/delete/',
    view_func=RoleNodeDeleteAPI.as_view('api-node-delete')
)
tasks_blueprint.add_url_rule(
    '/api/role/node/<uuid:pk>/rename/',
    view_func=RoleNodeRenameAPI.as_view('api-node-rename')
)
tasks_blueprint.add_url_rule(
    '/api/role/node/<uuid:pk>/copy/',
    view_func=RoleNodeCopyAPI.as_view('api-node-copy')
)
tasks_blueprint.add_url_rule(
    '/api/role/node/<uuid:pk>/file/content/',
    view_func=RoleNodeFileContentAPI.as_view('api-node-file-content')
)
tasks_blueprint.add_url_rule(
    '/api/role/node/<uuid:pk>/file/upload/',
    view_func=RoleNodeFileUploadAPI.as_view('api-node-file-upload')
)


# log
tasks_blueprint.add_url_rule('/api/log/adhoc/', view_func=AdHocExecuteLogAPI.as_view('api-log-adhoc'))
tasks_blueprint.add_url_rule('/log/adhoc/', view_func=AdHocExecuteLogView.as_view('log-adhoc'))
tasks_blueprint.add_url_rule('/api/log/playbook/', view_func=PlayBookExecuteLogAPI.as_view('api-log-playbook'))
tasks_blueprint.add_url_rule('/log/playbook/', view_func=PlayBookExecuteLogView.as_view('log-playbook'))
tasks_blueprint.add_url_rule('/playbook/<uuid:pk>/file/', view_func=PlayBookFileView.as_view('playbook-file'))
tasks_blueprint.add_url_rule('/api/log/role/', view_func=RoleExecuteLogAPI.as_view('api-log-role'))
tasks_blueprint.add_url_rule('/log/role/', view_func=RoleExecuteLogView.as_view('log-role'))
